home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8717 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: ix.netcom.com!netnews
  2. From: Amit Ramon <amitra@ix.netcom.com>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Visual C++ Serializing CStrings
  5. Date: 26 Feb 1996 04:39:44 GMT
  6. Organization: Netcom
  7. Message-ID: <4grdig$rhr@cloner4.netcom.com>
  8. References: <4gjjuo$poc@newshound.csrv.uidaho.edu>
  9. NNTP-Posting-Host: ix-stl3-16.ix.netcom.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-NETCOM-Date: Sun Feb 25  8:39:44 PM PST 1996
  14. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  15.  
  16. CArchive can serialize any CObject derive class that implement the
  17. Serialize(CArchive& ar) function. If e.g, CMyClass is derived from CObject, 
  18. and myObject is an instance of CMyClass, you can serialize it by calling 
  19. myObejct.Serialize(ar), where ar is an instance of CArchive. See the
  20. 'scribble' example that comes with VC++ for details. 
  21.  
  22. You can also serialize non CObject derive classes, like CString,
  23. by using operator<<(CArchive& ar, CString& str) or 
  24. operator>>(CArchive& ar, CString& str). For example:
  25.  
  26. CArchive ar;
  27.  
  28. // open ar and attach it to a file
  29.  
  30. CString str = "1234"
  31. ar << str;
  32.  
  33. This should work. Maybe you're trying to serialize an object that wasn't
  34. derived from CObject?
  35.  
  36. Amit.
  37.  
  38.